package javbot.mail;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MailParser {
	
	private static Pattern pattern = Pattern.compile(".*------.*Content-Type: text/plain;.*?\n.*?\n.*?\n.*?\n(.*?)------.*", Pattern.DOTALL);
 

	public static boolean isJavbotMail(String mail) {
		return mail.contains("Subject: Javbot Script");
	}

	public static String getJavbotScript(String mail) {
		 Matcher m = pattern.matcher(mail);	 
		 if(m.matches())
		 	return m.group(1).trim();
		 else 
			 return null;
	}

}
